<div class="white_box">
    <div class="box-body">
        <?php if (!$wallpaper) { ?>
            <h5>上传壁纸: <i class="fa fa-upload"></i></h5>
        <?php } else { ?>
            <h5>编辑壁纸 - <?php echo $wallpaper->wallpaper_hash; ?>: <i class="fa fa-upload"></i> /
                <a href="<?php echo $url ?>"><small><i class="fa fa-eye"></i> 预览</small></a> 
                <span class="pull-right">
                    <a class="text-danger" href="<?php echo $this->route_links->build_link('upload_wallpaper_delete', array('{hash}' => $wallpaper->wallpaper_hash)) ?>"><small class="text-danger"><i class="fa fa-trash-o"></i> 删除</small></a>
                </span>
                <span class="clearfix"></span>
            </h5>
        <?php } ?>
        <hr class="hr-sm"/>

        <?php if (validation_errors() || !empty($error)) { ?>
            <div class="alert alert-warning">
                <?php echo validation_errors(' ', '<br>'); ?>
                <?php if (!empty($error)) echo join('<br>', $error); ?>
            </div>
        <?php } ?>

        <?php echo form_open_multipart('', 'id="upload_image" class="label_normal"'); ?>

        <div class="row m_t_10">
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="image_name">壁纸名称</label>
                    <input type="text" value="<?php echo set_value('image_name', ($wallpaper ? $wallpaper->wallpaper_name : '')); ?>" name="image_name" id="image_name"
                           class="form-control input-sm"/>
                </div>
                <?php $type = set_value('upload_by'); ?>
                <?php if (!$image) { ?>
                    <div class="form-group">
                        <div class="upload_by_label">
                            <span class="pr10"> 上传壁纸(图片名称最好是英文或者数字文件名）: * </span>
                            <label class="radio-inline">
                                <input class="upload_by_click" value="file" <?php echo set_checkbox('upload_by', 'file', TRUE); ?> name="upload_by" type="radio"/> 本地上传
                            </label>
                            <label class="radio-inline">
                                <input class="upload_by_click" value="url" <?php echo set_checkbox('upload_by', 'url'); ?> name="upload_by" type="radio"/> 图片Url
                            </label>
                        </div>
                        <div class="tab_data">
                            <div id="file"
                                 class="<?php echo(!$type || ($type && $type == 'file') ? '' : 'hide'); ?>">
                                <input type="file" class="form-control input-sm" data-toggle="tooltip" data-placement="bottom" title="选择文件!" name="file"/>
                            </div>
                            <div id="url" class="<?php echo($type == 'url' ? '' : 'hide'); ?>">
                                <input type="url" name="file_url" value="<?php echo set_value('file_url'); ?>"
                                       class="form-control input-sm" placeholder="输入图片url地址">
                            </div>
                        </div>
                        <p class="help-block">
                            <?php if (config_item('minimum_width') || config_item('minimum_height')) { ?>
                                图片尺寸: <?php echo config_item('minimum_width'); ?>
                                x<?php echo config_item('minimum_height'); ?>
                            <?php } else { ?>
                                没有限制
                            <?php } ?>
                        </p>
                    </div>
                <?php } else { ?>
                    <input type="hidden" value="<?php echo $image; ?>" name="temp_image_path"/>
                    <img class="thumbnail" style="margin: 0 0 10px;width: 134px;" src="<?php echo $this->image_workshop->crop_image($image, 140, 86, 'MM', 'temp'); ?>" alt=""/>
                <?php } ?>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="category">选择分类 *</label>
                    <?php echo form_dropdown('category', array('' => '选择分类') + (is_array($categories) && !empty($categories) ? $categories : array()), set_value('category', ($wallpaper ? array($wallpaper->category_seq_id) : array('MM'))), 'class="form-control input-sm"'); ?>
                </div>
                <div class="form-group">
                    <label for="tags">壁纸标签</label>
                    <input type="text" value="<?php echo set_value('tags', ($wallpaper ? $wallpaper->tags : '')); ?>" name="tags" id="tags" data-role="tagsinput" class="form-control input-sm"/>

                    <p class="help-block">多个标签请用英文"," 隔开</p>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="author">图片来源</label>
                    <input type="text" value="<?php echo set_value('author', ($wallpaper ? $wallpaper->wallpaper_author : '')); ?>" name="author" id="author"
                           class="form-control input-sm"/>
                </div>
                <div class="form-group">
                    <label for="category">壁纸截取位置</label>
                    <?php echo form_dropdown('image_position', array(
                        'LT' => '左上',
                        'MT' => '中上',
                        'RT' => '右上',
                        'LM' => '左中',
                        'MM' => '居中',
                        'RM' => '右中',
                        'LB' => '左下',
                        'MB' => '中下',
                        'RB' => '右下'
                    ), ($wallpaper ? array($wallpaper->wallpaper_crop_position) : array('MM')), 'class="form-control input-sm"'); ?>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="author_url">来源网址</label>
                    <input type="url" value="<?php echo set_value('author_url', ($wallpaper ? $wallpaper->wallpaper_author_site : '')); ?>" name="author_url" id="author_url"
                           class="form-control input-sm"/>
                </div>
                <div class="form-group">
                    <label for="publish">发布设置</label>

                    <div>
                        <label class="radio-inline">
                            <input type="radio" name="publish" <?php echo set_radio('publish', '1', ($wallpaper ? ($wallpaper->wallpaper_status ? TRUE : FALSE) : TRUE)); ?> value="1"> 马上发布
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="publish" <?php echo set_radio('publish', '0', ($wallpaper ? (!$wallpaper->wallpaper_status ? TRUE : FALSE) : FALSE)); ?> value="0"> 存为草稿
                        </label>
                    </div>
                </div>
            </div>
        </div>


        <div class="form-group">
            <div class="checkbox">
                <label>
                    <input name="optional_data" <?php echo set_checkbox('optional_data', '1'); ?> type="checkbox" class="optional_data" value="1">
                    更多设置
                </label>
            </div>
        </div>
        <?php $optional_data = set_value('optional_data'); ?>
        <div id="optional_data" class="row <?php echo $optional_data ? '' : 'hide'; ?>">
            <hr class="hr-sm"/>
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="description">壁纸介绍</label>
                    <textarea name="description" class="form-control input-sm redactor_required" id="description" cols="30" rows="9"><?php echo set_value('description', ($wallpaper ? $wallpaper->wallpaper_description : '')); ?></textarea>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="metaTitle">SEO标题</label>
                    <input type="text" value="<?php echo set_value('metaTitle', ($wallpaper ? $wallpaper->wallpaper_metatitle : '')); ?>" name="metaTitle" id="metaTitle" class="form-control input-sm"/>
                </div>
                <div class="form-group">
                    <label for="metaDescription">SEO介绍</label>
                    <input type="text" value="<?php echo set_value('metaDescription', ($wallpaper ? $wallpaper->wallpaper_metadescription : '')); ?>" name="metaDescription" id="metaDescription" class="form-control input-sm"/>
                </div>
                <div class="form-group">
                    <label for="metaKeywords">SEO关键词</label>
                    <input type="text" value="<?php echo set_value('metaKeywords', ($wallpaper ? $wallpaper->wallpaper_metakeywords : '')); ?>" name="metaKeywords" data-role="tagsinput" id="metaKeywords" class="form-control input-sm"/>
                </div>
            </div>
        </div>

        <hr/>
        <div class="text-center">
            <button type="submit" name="upload_image_edit" class="btn btn-info">
                <i class="fa fa-edit"></i>
                保存发布
            </button>
            <button type="submit" name="upload_image" class="btn btn-success">
                <i class="fa fa-location-arrow"></i>
                新增发布
            </button>
        </div>

        <?php echo form_close(); ?>


    </div>
</div>